package _75

/*
时间复杂度：O(N^2)
空间复杂度：O(N)

*/

func checkValid(matrix [][]int) bool {
	n := len(matrix)
	for i := 0; i < n; i++ {
		arr1 := make([]int, n+1)
		arr2 := make([]int, n+1)
		for j := 0; j < n; j++ {
			t := matrix[i][j]
			arr1[t]++
			if arr1[t] != 1 {
				return false
			}

			k := matrix[j][i]
			arr2[k]++
			if arr2[k] != 1 {
				return false
			}
		}
	}
	return true
}
